(function(A) {
    A.fn.slide = function(B) {
        A.fn.slide.deflunt = {
            effect: "fade",
            autoPlay: false,
            delayTime: 1000,
            interTime: 5000,
            defaultIndex: 0,
            titCell: ".hd li",
            mainCell: ".bd",
            trigger: "click",
            scroll: 1,
            vis: 1,
            titOnClassName: "on",
            autoPage: false,
            prevCell: ".prev",
            nextCell: ".next"
        };
        return this.each(function() {
            var Q = A.extend({},
            A.fn.slide.deflunt, B);
            var D = Q.defaultIndex;
            var I = A(Q.prevCell, A(this));
            var E = A(Q.nextCell, A(this));
            var C = A(Q.titCell, A(this));
            var M = C.size();
            var O = A(Q.mainCell, A(this));
            var U = O.children().size();
            var S = 0;
            var T = 0;
            var N = 0;
            var J = 0;
            var K = Q.autoPlay;
            var H = null;
            var L = D;
            if (U < Q.vis) {
                return
            }
            if (M == 0) {
                M = U
            }
            if (Q.autoPage) {
                var G = U - Q.vis;
                M = 1 + parseInt(G % Q.scroll != 0 ? (G / Q.scroll + 1) : (G / Q.scroll));
                C.html("");
                for (var F = 0; F < M; F++) {
                    C.append("<li>" + (F + 1) + "</li>")
                }
                var C = A("li", C)
            }
            O.children().each(function() {
                if (A(this).width() > N) {
                    N = A(this).width();
                    T = A(this).outerWidth(true)
                }
                if (A(this).height() > J) {
                    J = A(this).height();
                    S = A(this).outerHeight(true)
                }
            });
            switch (Q.effect) {
            case "top":
                O.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; height:' + Q.vis * S + 'px"></div>').css({
                    "position": "relative",
                    "padding": "0",
                    "margin": "0"
                }).children().css({
                    "height": J
                });
                break;
            case "left":
                O.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; width:940px"></div>').css({
                    "width":
                    U * T,
                    "position": "relative",
                    "overflow": "hidden",
                    "padding": "0",
                    "margin": "0"
                }).children().css({
                    "float": "left",
                    "width": N
                });
                break;
            case "leftLoop":
            case "leftMarquee":
                O.children().clone().appendTo(O).clone().prependTo(O);
                O.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; width:width:940px"></div>').css({
                    "width":
                    U * T * 3,
                    "position": "relative",
                    "overflow": "hidden",
                    "padding": "0",
                    "margin-left": "120px",
                    "left": -U * T
                }).children().css({
                    "float": "left",
                    "width": N
                });
                break;
            case "topLoop":
            case "topMarquee":
                O.children().clone().appendTo(O).clone().prependTo(O);
                O.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; height:' + Q.vis * S + 'px"></div>').css({
                    "height": U * S * 3,
                    "position": "relative",
                    "padding": "0",
                    "margin": "0",
                    "top": -U * S
                }).children().css({
                    "height": J
                });
                break
            }
            var P = function() {
                switch (Q.effect) {
                case "fade":
                case "top":
                case "left":
                    if (D >= M) {
                        D = 0
                    } else {
                        if (D < 0) {
                            D = M - 1
                        }
                    }
                    break;
                case "leftMarquee":
                case "topMarquee":
                    if (D >= 2) {
                        D = 1
                    } else {
                        if (D < 0) {
                            D = 0
                        }
                    }
                    break;
                case "leftLoop":
                case "topLoop":
                    var Y = D - L;
                    if (M > 2 && Y == -(M - 1)) {
                        Y = 1
                    }
                    if (M > 2 && Y == (M - 1)) {
                        Y = -1
                    }
                    var W = Math.abs(Y * Q.scroll);
                    if (D >= M) {
                        D = 0
                    } else {
                        if (D < 0) {
                            D = M - 1
                        }
                    }
                    break
                }
                switch (Q.effect) {
                case "fade":
                    O.children().stop(true, true).eq(D).fadeIn(Q.delayTime).siblings().hide();
                    break;
                case "top":
                    O.stop(true, true).animate({
                        "top": -D * Q.scroll * S
                    },
                    Q.delayTime);
                    break;
                case "left":
                    O.stop(true, true).animate({
                        "left": -D * Q.scroll * T
                    },
                    Q.delayTime);
                    break;
                case "leftLoop":
                    if (Y < 0) {
                        O.stop(true, true).animate({
                            "left": -(U - W) * T
                        },
                        Q.delayTime,
                        function() {
                            for (var Z = 0; Z < W; Z++) {
                                O.children().last().prependTo(O)
                            }
                            O.css("left", -U * T)
                        })
                    } else {
                        O.stop(true, true).animate({
                            "left": -(U + W) * T
                        },
                        Q.delayTime,
                        function() {
                            for (var Z = 0; Z < W; Z++) {
                                O.children().first().appendTo(O)
                            }
                            O.css("left", -U * T)
                        })
                    }
                    break;
                case "topLoop":
                    if (Y < 0) {
                        O.stop(true, true).animate({
                            "top": -(U - W) * S
                        },
                        Q.delayTime,
                        function() {
                            for (var Z = 0; Z < W; Z++) {
                                O.children().last().prependTo(O)
                            }
                            O.css("top", -U * S)
                        })
                    } else {
                        O.stop(true, true).animate({
                            "top": -(U + W) * S
                        },
                        Q.delayTime,
                        function() {
                            for (var Z = 0; Z < W; Z++) {
                                O.children().first().appendTo(O)
                            }
                            O.css("top", -U * S)
                        })
                    }
                    break;
                case "leftMarquee":
                    var V = O.css("left").replace("px", "");
                    if (D == 0) {
                        O.animate({
                            "left": ++V
                        },
                        0,
                        function() {
                            if (O.css("left").replace("px", "") >= 0) {
                                for (var Z = 0; Z < U; Z++) {
                                    O.children().last().prependTo(O)
                                }
                                O.css("left", -U * T)
                            }
                        })
                    } else {
                        O.animate({
                            "left": --V
                        },
                        0,
                        function() {
                            if (O.css("left").replace("px", "") <= -U * T * 2) {
                                for (var Z = 0; Z < U; Z++) {
                                    O.children().first().appendTo(O)
                                }
                                O.css("left", -U * T)
                            }
                        })
                    }
                    break;
                case "topMarquee":
                    var X = O.css("top").replace("px", "");
                    if (D == 0) {
                        O.animate({
                            "top": ++X
                        },
                        0,
                        function() {
                            if (O.css("top").replace("px", "") >= 0) {
                                for (var Z = 0; Z < U; Z++) {
                                    O.children().last().prependTo(O)
                                }
                                O.css("top", -U * S)
                            }
                        })
                    } else {
                        O.animate({
                            "top": --X
                        },
                        0,
                        function() {
                            if (O.css("top").replace("px", "") <= -U * S * 2) {
                                for (var Z = 0; Z < U; Z++) {
                                    O.children().first().appendTo(O)
                                }
                                O.css("top", -U * S)
                            }
                        })
                    }
                    break
                }
                C.removeClass(Q.titOnClassName).eq(D).addClass(Q.titOnClassName);
                L = D
            };
            P();
            if (K) {
                if (Q.effect == "leftMarquee" || Q.effect == "topMarquee") {
                    D++;
                    H = setInterval(P, Q.interTime);
                    O.hover(function() {
                        if (K) {
                            clearInterval(H)
                        }
                    },
                    function() {
                        if (K) {
                            clearInterval(H);
                            H = setInterval(P, Q.interTime)
                        }
                    })
                } else {
                    H = setInterval(function() {
                        D++;
                        P()
                    },
                    Q.interTime);
                    A(this).hover(function() {
                        if (K) {
                            clearInterval(H)
                        }
                    },
                    function() {
                        if (K) {
                            clearInterval(H);
                            H = setInterval(function() {
                                D++;
                                P()
                            },
                            Q.interTime)
                        }
                    })
                }
            }
            var R;
            if (Q.trigger == "onclick") {
                C.hover(function() {
                    clearTimeout(R);
                    D = C.index(this);
                    R = window.setTimeout(P, 200)
                },
                function() {
                    if (!R) {
                        clearTimeout(R)
                    }
                })
            } else {
                C.click(function() {
                    D = C.index(this);
                    P()
                })
            }
            E.click(function() {
                D++;
                P()
            });
            I.click(function() {
                D--;
                P()
            })
        })
    }
})(jQuery);
jQuery(".fivebox").slide({
    mainCell: ".bd ul",
    effect: "leftLoop",
    vis: 1,
    scroll: 1,
    autoPlay: true
});
jQuery(".leftLoop").slide({
    mainCell: ".bd ul",
    effect: "leftLoop",
    vis: 3,
    scroll: 3,
    autoPlay: true
});